package com.zjuee.web.ledger.service.impl.handledata;

import com.zjuee.core.translation.handledata.impl.AbstractDataHandler;
import com.zjuee.service.PlanDangerService;
import com.zjuee.vo.PlanDangerVo;
import com.zjuee.base.model.common.plan.PlanDanger;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;
import java.util.Map;

@Component(value = "planDangerHandle")
public class PlanDangerHandle extends AbstractDataHandler {
    @Resource
    PlanDangerService planDangerService;

    @Override
    public <T> T getData(T data, Map<Object, Object> map, String... str) {
        PlanDanger planDanger = (PlanDanger) data;
        PlanDangerVo planDangerVo = new PlanDangerVo();
        BeanUtils.copyProperties(planDanger, planDangerVo);
        String wpdFeature = planDangerService.getFeatureByScode(planDanger.getWpdScode());
        planDangerVo.setWpdFeature(getStr(map, wpdFeature, str, 0));
        planDangerVo.setWpdDirectory(map.get(planDanger.getWpdScode() + "" + str[1]) == null ? "" : map.get(planDangerVo.getWpdScode() + "" + str[1]).toString());
        return (T) planDangerVo;
    }
}
